package cn.yunhe.entity;


import javax.persistence.*;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

@Entity(name = "街道")
@Table(name = "street")
public class Street implements Serializable {
    private int sid;
    private String sname;
    private District district;

    private Set<House> houseSet=new HashSet<>();

    public Street() {
    }

    public Street(String sname) {
        this.sname = sname;
    }

    public Street(String sname, District district) {
        this.sname = sname;
        this.district = district;
    }

    public Street(int sid, String sname, District district) {
        this.sid = sid;
        this.sname = sname;
        this.district = district;
    }

    @Id
    @GeneratedValue
    @Column(name = "sid")
    public int getSid() {
        return sid;
    }

    public void setSid(int sid) {
        this.sid = sid;
    }

    @Column(name = "sname")
    public String getSname() {
        return sname;
    }

    public void setSname(String sname) {
        this.sname = sname;
    }

    @ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.LAZY)
    @JoinColumn(name = "sdid")
    public District getDistrict() {
        if (district==null)
            district=new District();
        return district;
    }

    public void setDistrict(District district) {
        this.district = district;
    }

    @OneToMany(fetch = FetchType.LAZY,mappedBy = "street")
   /* @JoinColumn(name = "hsid")*/
    public Set<House> getHouseSet() {
        return houseSet;
    }

    public void setHouseSet(Set<House> houseSet) {
        this.houseSet = houseSet;
    }
}
